package cn.com.zpark;

import cn.com.zpark.utils.JDBCUtils01;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

/**
 * @PackageName: cn.com.zpark
 * @ClassName: JDBC_03_Update
 * @Description:
 * @author: RZS
 * @date: 2021/10/27  17:47
 */
public class JDBC_03_Update {
    public static void main(String[] args) {
        Connection conn = null;
        PreparedStatement stat = null;
        ResultSet res = null;

        try {
            // 获取连接
            conn = JDBCUtils01.getConn();
            // 编写sql
            String sql = "update user set pwd=? where id=?";
            // 获取PreparedStatement对象
            stat = conn.prepareStatement(sql);
            // 设置占位符
            stat.setString(1, "000000");
            stat.setInt(2, 1);

            // 执行sql
            stat.executeUpdate();


        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            // 关闭连接
            JDBCUtils01.close(null, stat, conn);
        }
    }
}
